<template>
  <el-tag :type="tagType" size="small">{{ typeText }}</el-tag>
</template>

<script>

const types = {
  1: { text: '单选题', type: 'success' },
  2: { text: '多选题', type: 'warning' },
  3: { text: '填空题', type: 'info' },
  9: { text: '编程题', type: 'danger' },
  99: { text: '未知', type: 'info' }
}

export default {
  name: 'QuestionTypeTag',
  props: {
    type: {
      type: Number,
      required: true,
      validator: (value) => [1, 2, 3, 9, 99].includes(value)
    }
  },
  computed: {
    typeText() {
      return types[this.type]?.text || '未知'
    },
    tagType() {
      return types[this.type]?.type || 'info'
    }
  }
}
</script>
